package com.smallpineapple.turing.service.guest.impl;

import com.smallpineapple.turing.dao.ResumeDao;
import com.smallpineapple.turing.dto.ResumeDTO;
import com.smallpineapple.turing.entity.Resume;
import com.smallpineapple.turing.enums.MyCustomizeErrorCode;
import com.smallpineapple.turing.exception.CustomizeException;
import com.smallpineapple.turing.service.guest.ResumeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Jack
 * @date 2019-11-18-8:43
 */
@Service
public class ResumeServiceImpl implements ResumeService {

    @Autowired
    ResumeDao resumeDao;

    @Override
    public void postResume(ResumeDTO resumeDTO) {

        Resume resume = new Resume();
        Resume dbResume = resumeDao.findResumeByResumeStudentId(resumeDTO.getResumeStudentId());
        if(dbResume != null){
            throw new CustomizeException(MyCustomizeErrorCode.RESUME_REPEAT);
        }
        BeanUtils.copyProperties(resumeDTO, resume);
        resumeDao.save(resume);

    }
}
